import 'package:enterprise_v6_app/app/components/special_operation/custom_title_chart_page.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/modules/application/basic_information/file_management/file_management_controller.dart';
import 'package:enterprise_v6_app/router/app_pages.dart';

/// 档案管理
class FileManagementPage extends StatelessWidget {
  FileManagementPage({super.key});

  final controller = Get.put(FileManagementController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Container(
            alignment: Alignment.topCenter,
            padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 12.w),
            child: SingleChildScrollView(
              child: Column(
                children: [
                  CustomTitleChartPage(
                    title: '合规性文件',
                    child: Column(children: [
                      _getContentView(
                        icon: AppImages.icon_file,
                        title: '正常',
                        num: controller.entity.compliance!.normalNum!,
                      ),
                      AppGaps.vGap16,
                      _getContentView(
                        icon: AppImages.icon_file,
                        title: '临期',
                        num: controller.entity.compliance!.expirationNum!,
                        iconColor: const Color(0xffFC9900),
                        numColor: const Color(0xffFC9900),
                      ),
                      AppGaps.vGap16,
                      _getContentView(
                        icon: AppImages.icon_file,
                        title: '过期',
                        num: controller.entity.compliance!.dueNum!,
                        iconColor: const Color(0xffFD6B6B),
                        numColor: const Color(0xffFD6B6B),
                      ),
                    ]),
                  ).clickOnce(() {
                    Get.toNamed(AppRoutes.fileList, arguments: 0);
                  }),
                  AppGaps.vGap16,
                  CustomTitleChartPage(
                    title: '证照文件',
                    child: Column(children: [
                      _getContentView(
                        icon: AppImages.icon_papers,
                        title: '正常',
                        num: controller.entity.certificate!.normalNum!,
                      ),
                      AppGaps.vGap16,
                      _getContentView(
                        icon: AppImages.icon_papers,
                        title: '临期',
                        num: controller.entity.certificate!.expirationNum!,
                        iconColor: const Color(0xffFC9900),
                        numColor: const Color(0xffFC9900),
                      ),
                      AppGaps.vGap16,
                      _getContentView(
                        icon: AppImages.icon_papers,
                        title: '过期',
                        num: controller.entity.certificate!.dueNum!,
                        iconColor: const Color(0xffFD6B6B),
                        numColor: const Color(0xffFD6B6B),
                      ),
                    ]),
                  ).clickOnce(() {
                    Get.toNamed(AppRoutes.fileList, arguments: 1);
                  }),
                  AppGaps.vGap16,
                  CustomTitleChartPage(
                    title: '三同时',
                    child: Column(children: [
                      _getContentView(
                        icon: AppImages.icon_design,
                        title: '设计',
                        num: controller.entity.projectSame!.design!,
                      ),
                      AppGaps.vGap16,
                      _getContentView(
                        icon: AppImages.icon_construction,
                        title: '施工',
                        num: controller.entity.projectSame!.construction!,
                      ),
                      AppGaps.vGap16,
                      _getContentView(
                        icon: AppImages.icon_trial_production,
                        title: '试生产',
                        num: controller.entity.projectSame!.trialProduction!,
                      ),
                      AppGaps.vGap16,
                      _getContentView(
                        icon: AppImages.icon_delete,
                        title: '取消',
                        iconColor: const Color(0xFF5C6DFF),
                        num: controller.entity.projectSame!.cancel!,
                      ),
                    ]),
                  ).clickOnce(() {
                    Get.toNamed(AppRoutes.threeSameTime);
                  }),
                ],
              ),
            ),
          );
        });
  }

  // 获取内容显示
  Widget _getContentView({
    required String icon,
    required String title,
    required int num,
    Color? iconColor,
    Color? numColor,
  }) {
    return Row(
      children: [
        SvgPicture.asset(
          icon,
          colorFilter: iconColor == null ? null : ColorFilter.mode(iconColor, BlendMode.srcIn),
        ),
        AppGaps.hGap6,
        Text(
          title,
          style: TextStyle(
            fontSize: 14.sp,
            height: 1.2,
            fontWeight: FontWeight.w400,
            color: const Color(0xffA5A6B5),
          ),
        ),
        AppGaps.hGap30,
        Expanded(
          child: Container(
            alignment: Alignment.center,
            height: 2.w,
            decoration: const BoxDecoration(
              gradient: LinearGradient(
                begin: Alignment.centerLeft,
                end: Alignment.centerRight,
                colors: [
                  Color(0xFFffffff),
                  Color(0xFF5C6DFF),
                ],
              ),
            ),
          ),
        ),
        AppGaps.hGap10,
        Text(
          num.toString(),
          style: TextStyle(
            fontSize: 14.sp,
            height: 1.2,
            fontWeight: FontWeight.w500,
            color: numColor ?? const Color(0xff5C6DFF),
          ),
        ),
      ],
    );
  }
}
